<script>
var pageset=1;
var pageset2=1;
var statusset=1;
var useridset=0;
var datamemberjson={};
function getmemberpos()
{
var code='';
$.get(serviceinfo+'getmemberorder', { page:pageset ,status:statusset}, function(data) { 
$('.shopmember').html(data.countallshop);
$('.noshopmember').html(data.countallnoshop);
if(data.data.length)
{

//console.log(data.data);
$.each( data.data, function( key, value ) {
datamemberjson[value.user.userid]=value;
code += '<div class="wrpMemLstPOS clBg3 clBd2 bdFull" onclick="openpopupmemberdata('+value.user.userid+')">\n';
code += '<div class="wrpTopMemLst">\n';
code += '<div class="memLstPOS">\n';
code += '<img src="'+value.user.simguser.newpath+'" alt="img">\n';
code += '<div class="wrpCtmName">\n';
code += '<div class="wrpInCtmName">\n';
code += '<div class="ctmName">\n';
var displayname='';
if(value.user.displayname=="")
{
   displayname=value.user.username;

}else
{

   displayname=value.user.displayname;
}


code += '<span class="clTxtPOSB fs05 cutTxt">'+displayname+'</span>\n';
code += '</div>\n';
code += '<div class="ctmCred">\n';
code += '<span class="clTxtPOSB fs02">'+value.user.credit+' Credit</span>\n';
code += '</div>\n';


if(value['user']['disid']!='0'&&value['user']['tumid']!='0')
{
code +='<div class="ctmRoute clearfix"><span class="icoPOS icoCtmRoute icoCtmRoute10"></span><span class="lctRoute clTxtPOSB cutTxt fs02">'+value['user']['disname']+' - '+value['user']['tumname']+'</span></div>';

}


code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="wrpBtmMemLst">\n';
code += '<div class="wrpOutBtmMemLst clBg5 clearfix">\n';
code += '<div class="wrpWkMem">\n';
code += '<span class="fs07 clTxtPOSB">'+value.countorderweek+'</span>\n';
code += '<span class="fs02 clTxtPOSB">Weekly</span>\n';
code += '</div>\n';
code += '<div class="wrpMtMem">\n';
code += '<span class="fs07 clTxtPOSB">'+value.countordermonth+'</span>\n';
code += '<span class="fs02 clTxtPOSB">Monthly</span>\n';
code += '</div>\n';
code += '<div class="wrpTtMem">\n';
code += '<span class="fs07 clTxtPOSB">'+value.countorderall+'</span>\n';
code += '<span class="fs02 clTxtPOSB">Total</span>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>\n';
code += '</div>';
});
if(pageset==1)
{
if(statusset==1)
{
setpagination('.wrprPgPOS .wrpPgPOS',data.countallshop,8,'getmemberpos');
}else
{
setpagination('.wrprPgPOS .wrpPgPOS',data.countallnoshop,8,'getmemberpos');

}

 }
$('.wrprBdMemPOS .wrpBdMemPOS').html(code);



}
});
}

function openpopupmemberdata(userid)
{
useridset=userid;
var value=datamemberjson[userid];


var displayname='';
if(value.user.displayname=="")
{
   displayname=value.user.username;

}else
{

   displayname=value.user.displayname;
}


$('.wrprPopMem .ctmName span').html(displayname);
$('.wrprPopMem .ctmCred span').html(value.user.credit+' Credit');




if(value['user']['disid']!='0'&&value['user']['tumid']!='0')
{
//code +='<div class="ctmRoute clearfix"><span class="icoPOS icoCtmRoute icoCtmRoute10"></span><span class="lctRoute clTxtPOSB cutTxt fs02">'+value['user']['disname']+' - '+value['user']['tumname']+'</span></div>';

$('.wrprPopMem .ctmRoute .lctRoute.clTxtPOSB').html(value['user']['disname']+' - '+value['user']['tumname']);
$('.wrprPopMem .ctmRoute').show();
}else
{
$('.wrprPopMem .ctmRoute').hide();

}


if(value.user.birthdate!='0000-00-00')
{
var res = value.user.birthdate.split("-"); 
$('.wrprPopMem .bdaysetmem').html(res[2]+'/'+res[1]+'/'+res[0]);

}else
{
$('.wrprPopMem .bdaysetmem').html('N/A');

}



if(value.user.question.length)
{
if(value.user.question.gender==2)
{
$('.wrprPopMem .gensetmem').html('Female');

}else
{
$('.wrprPopMem .gensetmem').html('Male');

}


if(value.user.question.age==1)
{
$('.wrprPopMem .agesetmem').html('Kid');

}else if(value.user.question.age==2)
{
$('.wrprPopMem .agesetmem').html('Teen');

}else if(value.user.question.age==3)
{
$('.wrprPopMem .agesetmem').html('Adult');

}else
{
$('.wrprPopMem .agesetmem').html('Old');

}


}else
{
$('.wrprPopMem .agesetmem').html('N/A');
$('.wrprPopMem .gensetmem').html('N/A');
}

$('.wrprPopMem .telsetmem').html(value.user.phone);
$('.wrprPopMem .emailsetmem').html(value.user.email);
$('.wrprPopMem .addresssetmem').html(value.user.address);

var dataplugin=value.user;
if(dataplugin.lat!='0.000000000000000')
{
var mapset='<a href="http://maps.google.com/?q='+dataplugin.lat+','+dataplugin.lng+'" target="_blank"><img width="100%" height="200" src="http://maps.googleapis.com/maps/api/staticmap?center='+dataplugin.lat+','+dataplugin.lng+'&zoom=17&size=300x200&markers='+dataplugin.lat+','+dataplugin.lng+'&sensor=true" ></a>';
$('.wrprPopMem .mapMem').html(mapset);
}else
{
$('.wrprPopMem .mapMem').html('');
}

$('.wrprPopMem .imgsetmem').attr('src',dataplugin.simguser.newpath);

addroworderlist(value);
$('.wrprPopMem').show();


}
function openinfomation()
{
$('.wrprPopMem .forminformationpop').show();
$('.wrprPopMem .formorderhispop').hide();
}
function openorderhistory()
{
$('.wrprPopMem .formorderhispop').show();
$('.wrprPopMem .forminformationpop').hide();
}
function toggleorderdata(orderid)
{
$('#orderidset-'+orderid).slideToggle("fast");
}
function addroworderlist(value)
{

var code='';
if(value.orderlist.data.length)
{

$.each( value.orderlist.data, function( keyorder, valueorder ) {
code += '<div class="bdOutHtrPopMem clBd2 bdBtm">\n';
code += '<div class="bdInHtrPopMem clearfix">\n';
code += '<div class="bdHtrMem colDate">\n';
code += '<span class="clTxtPOSB fs04">'+valueorder.newdate+'</span>\n';
code += '</div>\n';
code += '<div class="bdHtrMem colPd">\n';
code += '<span class="clTxtPOSB fs04">'+valueorder.orderid+'</span>\n';
code += '</div>\n';
code += '<div class="bdHtrMem colPrc">\n';
code += '<span class="clTxtPOSB fs04">'+valueorder.sumall+'</span>\n';
code += '</div>\n';
code += '<div class="wrpExpOrdHtr">\n';
code += '<button class="btnPOSW btnExpOrdHtr fs07" onclick="toggleorderdata('+valueorder.orderid+')">\n';
code += '<span class="icoPOS icoExpOrd"></span>\n';
code += '</button>\n';
code += '</div>\n';
code += '</div>\n';
code += '<div class="dtHtrPopMem clBg4" id="orderidset-'+valueorder.orderid+'" style="display:none">\n';
if(valueorder.suborder.length)
{
$.each( valueorder.suborder, function( keysuborder, valuesuborder ) {
var titleset=valuesuborder.title;
if(valuesuborder.title=="")
{
titleset=valuesuborder.productlist.title;

}
code += '<div class="dtInHtrPopMem clearfix">\n';
code += '<div class="dtHtrMem colDt">\n';
code += '<span class="clTxtPOSB cutTxt fs04"><em>'+valuesuborder.count+'</em>'+titleset+'</span>\n';
if(valuesuborder.note!="")
{
code += '<span class="clTxtPOSB fs03">'+valuesuborder.note+'</span>\n';
}

code += '</div>\n';
code += '<div class="dtHtrMem colPrc">\n';
code += '<span class="clTxtPOSB fs04">'+valuesuborder.price+'</span>\n';
code += '</div>\n';
code += '</div>';

});

}


code += '</div>\n';
code += '</div>';
});

setpaginationorder('.wrprPopMem .wrprPgPopPOS .wrpPgPOS',value.orderlist.count,20,'loadorderlistbyuserid');
}

$('.wrprPopMem #pagepopmem').html(code);


}

function loadorderlistbyuserid()
{
$.post(serviceinfo+'getorderlistdatabyuserids', { page:pageset2 ,userid:useridset}, function(data) { 
addroworderlist(data);
});

}

function setpagination(div,pageallset,rowpage,func)
{

$(div).pagination({
        items: pageallset,
        itemsOnPage: rowpage,
        cssStyle: 'light-theme',
        reverse:0,
        onPageClick: function(pageNumber, event) {
                   
                   
                   
                   pageset=pageNumber;
                   eval(func+"()")
       
                    // Callback triggered when a page is clicked
                    // Page number is given as an optional parameter
                }
    });

}

function setpaginationorder(div,pageallset,rowpage,func)
{

$(div).pagination({
        items: pageallset,
        itemsOnPage: rowpage,
        cssStyle: 'light-theme',
        reverse:0,
        onPageClick: function(pageNumber, event) {
                   
                   
                   
                   pageset2=pageNumber;
                   eval(func+"()")
       
                    // Callback triggered when a page is clicked
                    // Page number is given as an optional parameter
                }
    });

}


function changememberstatus(statusset2)
{

pageset=1;
statusset=statusset2;
getmemberpos();

}
getmemberpos();
</script>
